<?php
header('Content-Type:text/plain;charset=utf-8');
header('Access-Control-Allow-Origin:*');
error_reporting(0);
$datfile = "./cache/ip.dat";
if ($_GET['ip']) {
    file_put_contents($datfile, ',' . $_GET['ip'], FILE_APPEND);
    exit('写入成功');
} else {
    $ips = file_get_contents($datfile);
    $ipa = explode(',', $ips);
    $ip = $_SERVER['REMOTE_ADDR'];
    if (in_array($ip, $ipa)) {
        echo json_encode(['code' => 0, 'ip' => $ip]);
    } else {

        echo json_encode(['code' => 200, 'ip' => $ip]);
    }
}

?>